/**
 * 图片加载错误处理器,避免编写不当，导致图片加载死循环狂闪
 * @param {*} imgList
 */
var ImgLoadErrorHandler = function (imgList) {
    var index = 0;
    return function (e) {
        //如果备选图片路径都用完了，停止处理，这样就不报错了
        if (index >= imgList.length) {
            this.alt = "图片加载失败";
            return;
        }
        var img = imgList[index];
        this.src = img;
        index++;
    };
};
//程序入口
window.main = function ($) {
    var imgList = [
        "img/img1.png",
        "img/img2.png",
        "img/img3.png",
        "img/img4.png",
        "img/defaultx.png",
    ];

    pic1.onerror = ImgLoadErrorHandler(imgList);
    pic1.src = "img/img0.png";

    $("#pic2").handleImgError(imgList);
    $("#pic2").prop("src", "img/img0.png");
};
